package site.param.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
import site.param.init.ClientLoadParamter;

/**
 * Created by Administrator on 2017/1/4.
 */
public class ParameterAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
    private static Logger logger = LoggerFactory.getLogger(ParameterInitBean.class);

    public ParameterAwareBeanPostProcessor() {
    }

    // 接口方法、实例化Bean之后调用
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof ParameterInitBean) {
            new ClientLoadParamter((ParameterInitBean) bean);
            logger.info("new ClientLoadParamter ,init parameter!!!");
        }
        return bean;
    }

}
